package com.googlecode.jascii.util;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.ArrayUtils;

import com.googlecode.jascii.TdResult;
import com.googlecode.jascii.TrResult;

public class RotationUtil {

	public static  List  rotation(List trsList)
	{
		List rotationStr = new ArrayList();
		int row =0;
		for (int i = trsList.size()-1 ; i >= 0; i--) {
			
			TrResult tr = (TrResult) trsList.get(i);
//			row = tr.getWidth();
			String str = tr.toString();
			if(row < str.length())row = str.length();
			rotationStr.add(tr.toString());
		}
		
		String[] strArray =  (String[])rotationStr.toArray(new String[rotationStr.size()]);
		
		List rotationTr = new ArrayList();
		for(int i=0;i<row ; i++)
		{
			TrResult tr = new TrResult();
			for(int ia=0;ia<strArray.length;ia++)
			{
				if(strArray[ia].length() > i)
				{
					String strmp = String.valueOf(strArray[ia].charAt(i));
					tr.append(new TdResult(String.valueOf( strArray[ia].charAt(i)), 2,TdResult.TD_STYLE_RIGHT));//for Chinese char type
				}
			}
			rotationTr.add(tr);
			
		}
		return rotationTr;
	}
	

}
